package services;

import domain.entities.Mail;

/**
 * Created with IntelliJ IDEA.
 * User: vgonzalez
 * Date: 09/11/12
 * Time: 18:01
 * To change this template use File | Settings | File Templates.
 */
public class CriteriaMail extends Criteria {
    private Mail mail;

    public CriteriaMail(Mail mail) {
        this.mail = mail;
    }

    @Override
    public boolean isIn(Object element) {
        boolean isIn = true;
        Mail other = (Mail)element;

        isIn &= isSubstring(mail.getEmail(), other.getEmail());
        isIn &= (mail.getPais() == null || mail.getPais().getId() == null || mail.getPais().getId().equals(other.getPais().getId()));

        return isIn;
    }

}
